﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.订单一览新.销售确认单
{
    public partial class Form查询发运信息 : DevExpress.XtraEditors.XtraForm
    {
        private List<CustomerSaleQueryDTO> customerSaleQueryDTOs未发运 = new List<CustomerSaleQueryDTO>();
        private String mobile { get; set; }

        public Form查询发运信息(String mobile,String barcode)
        {
            InitializeComponent();
            this.mobile = mobile;
            this.刷新发运记录(mobile);
        }
        private void 刷新发运记录(String mobile)
        {
            List<CustomerSaleQueryDTO> customerSaleQueryDTOs = 销售确认Service.getRecentCustomerMTOInfo(mobile);
            List<CustomerSaleQueryDTO> customerSaleQueryDTOs已发运 = new List<CustomerSaleQueryDTO>();
            this.customerSaleQueryDTOs未发运.Clear();
            //已发运和未发运分到两个gridcontrol
            foreach (CustomerSaleQueryDTO customerSaleQueryDTO in customerSaleQueryDTOs)
            {
                if (customerSaleQueryDTO.orderShippedDTOS.Count > 0)
                {
                    customerSaleQueryDTOs已发运.Add(customerSaleQueryDTO);
                }
                else
                {
                    this.customerSaleQueryDTOs未发运.Add(customerSaleQueryDTO);
                }
            }
            this.gridControl未发运.DataSource = this.customerSaleQueryDTOs未发运;
            this.gridView未发运.RefreshData();
            this.gridControl已发运.DataSource = customerSaleQueryDTOs已发运;
            this.gridView已发运.RefreshData();
        }
        
        private void simpleButton顺丰发运_Click(object sender, EventArgs e)
        {
            List<CustomerTagRecordDTO> customerTagRecordDTOs = new List<CustomerTagRecordDTO>();
            foreach (CustomerSaleQueryDTO item in this.customerSaleQueryDTOs未发运)
            {
                customerTagRecordDTOs.Add(item.customerTagRecordDTO);
            }
            new Form客套顺丰发运匹配(customerTagRecordDTOs).ShowDialog();
            this.刷新发运记录(this.mobile);
        }

        private void gridView未发运_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺码0"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
            }
        }

        private void gridView已发运_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺码"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
            }
        }
    }
}
